home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / gnu / cvs-1_3.lha / cvs-1.3 / contrib / rcs-to-cvs < prev    next >
Text File  |  1992-04-09  |  6KB  |  209 lines

  1. #!/bin/csh
  2. #
  3. # rcs-to-cvs,v 1.3 1992/04/10 03:04:25 berliner Exp
  4. # Contributed by Per Cederqvist <ceder@lysator.liu.se>.
  5. #
  6. #   Copyright (c) 1989, Brian Berliner
  7. #
  8. #   You may distribute under the terms of the GNU General Public License
  9. #   as specified in the README file that comes with the CVS 1.0 kit.
  10. #
  11. #############################################################################
  12. #                                        #
  13. # This script is used to check in sources that previously was under RCS or  #
  14. # no source control system.                              #
  15. #                                        #
  16. #    Usage: rcs-to-cvs repository                         #
  17. #                                        #
  18. # The repository is the directory where the sources should            #
  19. # be deposited. 
  20. #                                        #
  21. # checkin traverses the current directory, ensuring that an             #
  22. # identical directory structure exists in the repository directory.  It        #
  23. # then checks the files in in the following manner:                #
  24. #                                        #
  25. #        1) If the file doesn't yet exist, check it in             #
  26. #            as revision 0.1                        #
  27. #                                        #
  28. # The script also is somewhat verbose in letting the user know what is        #
  29. # going on.  It prints a diagnostic when it creates a new file, or updates  #
  30. # a file that has been modified on the trunk.                       #
  31. #                                        #
  32. #############################################################################
  33.  
  34. set vbose = 0
  35. set message = ""
  36. set cvsbin = /usr/gnu/bin
  37. set rcsbin = /usr/gnu/bin
  38. set grep = /bin/grep
  39. set message_file = /usr/tmp/checkin.$$
  40. set got_one = 0
  41.  
  42. if ( $#argv < 1 ) then
  43.     echo "Usage: rcs-to-cvs [-v] [-m message] [-f message_file] repository"
  44.     exit 1
  45. endif
  46. while ( $#argv )
  47.     switch ( $argv[1] )
  48.         case -v:
  49.             set vbose = 1
  50.         breaksw
  51.     case -m:
  52.         shift
  53.         echo $argv[1] > $message_file
  54.         set got_one = 1
  55.         breaksw
  56.     case -f:
  57.         shift
  58.         set message_file = $argv[1]
  59.         set got_one = 2
  60.         breaksw
  61.     default:
  62.         break
  63.     endsw
  64.     shift
  65. end
  66. if ( $#argv < 1 ) then
  67.     echo "Usage: rcs-to-cvs [-v] [-m message] [-f message_file] repository"
  68.     exit 1
  69. endif
  70. set repository = $argv[1]
  71. shift
  72.  
  73. if ( ! $?CVSROOT ) then
  74.     echo "Please set the environmental variable CVSROOT to the root"
  75.     echo "    of the tree you wish to update"
  76.     exit 1
  77. endif
  78.  
  79. if ( $got_one == 0 ) then
  80.     echo "Please Edit this file to contain the RCS log information" >$message_file
  81.     echo "to be associated with this file (please remove these lines)">>$message_file
  82.     if ( $?EDITOR ) then
  83.     $EDITOR $message_file > /dev/tty
  84.     else
  85.     /usr/ucb/vi $message_file > /dev/tty
  86.     endif
  87.     set got_one = 1
  88. endif
  89.  
  90. umask 22
  91.  
  92. set update_dir = ${CVSROOT}/${repository}
  93. if ( -d SCCS ) then
  94.     echo SCCS files detected!
  95.     exit 1
  96. endif
  97. if ( -d RCS ) then
  98.     $rcsbin/co RCS/* >& /dev/null
  99. endif
  100. foreach name ( * .[a-zA-Z0-9]* )
  101.     echo $name
  102.     if ( "$name" == SCCS ) then 
  103.     continue
  104.     endif
  105.     if ( "$name" == RCS ) then 
  106.     continue
  107.     endif
  108.     if ( $vbose ) then 
  109.     echo "Updating ${repository}/${name}"
  110.     endif
  111.     if ( -d "$name" ) then
  112.     if ( ! -d "${update_dir}/${name}" ) then
  113.         echo "WARNING: Creating new directory ${repository}/${name}"
  114.         mkdir "${update_dir}/${name}"
  115.         if ( $status ) then
  116.         echo "ERROR: mkdir failed - aborting"
  117.         exit 1
  118.         endif
  119.     endif
  120.     chdir "$name"
  121.     if ( $status ) then
  122.         echo "ERROR: Couldn\'t chdir to "$name" - aborting" 
  123.         exit 1
  124.     endif
  125.     if ( $vbose ) then
  126.         rcs-to-cvs -v -f $message_file "${repository}/${name}"
  127.     else
  128.         rcs-to-cvs -f $message_file "${repository}/${name}"
  129.     endif
  130.     if ( $status ) then 
  131.         exit 1
  132.     endif
  133.     chdir ..
  134.     else    # if not directory 
  135.     if ( ! -f "$name" ) then
  136.         echo "WARNING: "$name" is neither a regular file" 
  137.         echo "       nor a directory - ignored"
  138.         continue
  139.     endif
  140.     set file = "${update_dir}/${name},v"
  141.     set new = 0
  142.     set comment = ""
  143.     grep -s '\$Log.*\$' "${name}"
  144.     if ( $status == 0 ) then    # If $Log keyword
  145.         set myext = ${name:e}
  146.         set knownext = 0
  147.         foreach xx ( "c" "csh" "e" "f" "h" "l" "mac" "me" "mm" "ms" "p" "r" "red" "s" "sh" "sl" "cl" "ml" "el" "tex" "y" "ye" "yr" "" )
  148.         if ( "${myext}" == "${xx}" ) then
  149.             set knownext = 1
  150.             break
  151.         endif
  152.         end
  153.         if ( $knownext == 0 ) then
  154.         echo For file ${file}:
  155.         grep '\$Log.*\$' "${name}"
  156.         echo -n "Please insert a comment leader for file ${name} > "
  157.         set comment = $<
  158.         endif
  159.     endif
  160.     if ( ! -f "$file" ) then    # If not exists in repository
  161.         if ( ! -f "${update_dir}/Attic/${name},v" ) then
  162.             echo "WARNING: Creating new file ${repository}/${name}"
  163.         if ( -f RCS/"${name}",v ) then
  164.             echo "MSG: Copying old rcs file."
  165.             cp RCS/"${name}",v "$file"
  166.         else
  167.                if ( "${comment}" != "" ) then
  168.                 $rcsbin/rcs -q -i -c"${comment}" -t${message_file} -m'.' "$file"
  169.             endif
  170.                 $rcsbin/ci -q -u0.1 -t${message_file} -m'.' "$file" 
  171.                 if ( $status ) then
  172.                 echo "ERROR: Initial check-in of $file failed - aborting"
  173.                 exit 1
  174.                 endif
  175.                 set new = 1
  176.         endif
  177.         else 
  178.         set file = "${update_dir}/Attic/${name},v"
  179.         echo "WARNING: IGNORED: ${repository}/Attic/${name}"
  180.         continue
  181.         endif
  182.     else    # File existed 
  183.         echo ERROR: File exists: Ignored: "$file"
  184.         continue
  185. #        set headbranch = `sed -n '/^head/p; /^branch/p; 2q' $file`
  186. #        if ( $#headbranch != 2 && $#headbranch != 4 ) then
  187. #        echo "ERROR: corrupted RCS file $file - aborting"
  188. #        endif
  189. #        set head = "$headbranch[2]"
  190. #        set branch = ""
  191. #        if ( $#headbranch == 4 ) then
  192. #        set branch = "$headbranch[4]"
  193. #        endif
  194. #        if ( "$head" == "1.1;" && "$branch" != "1.1.1;" ) then
  195. #        ${rcsbin}/rcsdiff -q -r1.1 $file > /dev/null
  196. #        if ( ! $status ) then
  197. #            set new = 1
  198. #        endif
  199. #        else
  200. #            if ( "$branch" != "1.1.1;" ) then
  201. #            echo -n "WARNING: Updating locally modified file "
  202. #            echo    "${repository}/${name}"
  203. #            endif
  204. #        endif
  205.     endif
  206.     endif
  207. end
  208. if ( $got_one == 1 ) rm $message_file
  209.